package com.hw.servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "FServlet",urlPatterns = "/ff")
public class FServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setAttribute("numa","ff");
        RequestDispatcher rr =request.getRequestDispatcher("//gg");
        System.out.println("++++");
        rr.forward(request,response);
        System.out.println("====");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");//更改request传入的编码格式
         response.setCharacterEncoding("UTF-8");
        String s=request.getParameter("s");

        request.getRequestDispatcher("index.jsp").include(request,response);

        PrintWriter writer=response.getWriter();

        writer.print("<h1>"+s+"</h1>");

    }
}
